home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / createmsgport.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  93 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createmsgport.c,v 1.4 1996/10/24 15:50:46 aros Exp $
  4.     $Log: createmsgport.c,v $
  5.     Revision 1.4  1996/10/24 15:50:46  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.3  1996/08/01 17:41:08  digulla
  9.     Added standard header for all files
  10.  
  11.     Desc:
  12.     Lang: english
  13. */
  14. #include <exec/memory.h>
  15. #include <exec/ports.h>
  16. #include <exec/execbase.h>
  17. #include <aros/libcall.h>
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <clib/exec_protos.h>
  23.  
  24.     AROS_LH0(struct MsgPort *, CreateMsgPort,
  25.  
  26. /*  SYNOPSIS */
  27.  
  28. /*  LOCATION */
  29.     struct ExecBase *, SysBase, 111, Exec)
  30.  
  31. /*  FUNCTION
  32.     Create a new message port. A signal will be allocated and the message
  33.     port set to signal you task
  34.  
  35.     INPUTS
  36.  
  37.     RESULT
  38.     Pointer to messageport structure
  39.  
  40.     NOTES
  41.  
  42.     EXAMPLE
  43.  
  44.     BUGS
  45.  
  46.     SEE ALSO
  47.  
  48.     INTERNALS
  49.  
  50.     HISTORY
  51.  
  52. ******************************************************************************/
  53. {
  54.     AROS_LIBFUNC_INIT
  55.  
  56.     struct MsgPort *ret;
  57.  
  58.     /* Allocate memory for struct MsgPort */
  59.     ret=(struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
  60.     if(ret!=NULL)
  61.     {
  62.     BYTE sb;
  63.  
  64.     /* Allocate a signal bit */
  65.     sb=AllocSignal(-1);
  66.     if(sb!=-1)
  67.     {
  68.         /* Initialize messageport structure. First set signal bit. */
  69.         ret->mp_SigBit=sb;
  70.  
  71.         /* Clear the list of messages */
  72.         ret->mp_MsgList.lh_Head=(struct Node *)&ret->mp_MsgList.lh_Tail;
  73.         /* ret->mp_MsgList.lh_Tail=NULL; */
  74.         ret->mp_MsgList.lh_TailPred=(struct Node *)&ret->mp_MsgList.lh_Head;
  75.  
  76.         /* Set port to type 'signalling' */
  77.         ret->mp_Flags=PA_SIGNAL;
  78.  
  79.         /* Finally set task to send the signal to. */
  80.         ret->mp_SigTask=SysBase->ThisTask;
  81.  
  82.         /* Now the port is ready for use. */
  83.         return ret;
  84.     }
  85.     /* Couldn't get the signal bit. Free the memory. */
  86.     FreeMem(ret,sizeof(struct MsgPort));
  87.     }
  88.     /* function failed */
  89.     return NULL;
  90.     AROS_LIBFUNC_EXIT
  91. } /* CreateMsgPort */
  92.  
  93.